﻿using Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hejian_PCBA_Test.Procdure
{
    internal class TestResultSingle : NotifyBase
    {
        private double _innerTesistance;

        public double InnerTesistance
        {
            get { return _innerTesistance; }
            set
            {
                _innerTesistance = value;
                this.DoNotify();
            }
        }

        private int _sleepTime;

        /// <summary>
        /// 等待延时
        /// </summary>
        public int SleepTime
        {
            get { return _sleepTime; }
            set
            {
                _sleepTime = value;
                this.DoNotify();
            }
        }

        private bool? _status;

        /// <summary>
        /// null-wait false-ng true-ok
        /// </summary>
        private int _relayNo;

        public int RelayNo
        {
            get { return _relayNo; }
            set
            {
                _relayNo = value;
                this.DoNotify();
            }
        }

        private int _gndRelayNo;

        public int GndRelayNo
        {
            get { return _gndRelayNo; }
            set
            {
                _gndRelayNo = value;
                this.DoNotify();
            }
        }

        private string _tp;

        public string TP
        {
            get { return _tp; }
            set
            {
                _tp = value;
                this.DoNotify();
            }
        }

        private double _readValue;

        /// <summary>
        /// 阻值|电压 读值
        /// </summary>
        public double ReadValue
        {
            get { return _readValue; }
            set
            {
                _readValue = value;

                this.DoNotify();
            }
        }

        /// <summary>
        /// 更新测试状态
        /// </summary>
        public void UpdateStatus()
        {
            if (LowerLimit != -1)
            {
                if (ReadValue <= LowerLimit)
                {
                    Status = false;
                    return;
                }
            }
            if (UpperLimit != -1)
            {
                if (ReadValue >= UpperLimit)
                {
                    Status = false;
                    return;
                }
            }
            Status = true;
        }

        private double _upperLimit;

        /// <summary>
        /// 上限
        /// </summary>
        public double UpperLimit
        {
            get { return _upperLimit; }
            set
            {
                _upperLimit = value;
                this.DoNotify();
            }
        }

        private double _lowerLimit;

        /// <summary>
        /// 下限
        /// </summary>
        public double LowerLimit
        {
            get { return _lowerLimit; }
            set
            {
                _lowerLimit = value;
                this.DoNotify();
            }
        }

        /// <summary>
        /// 测试状态 true=Pass false=Failed null=waiting
        /// </summary>
        public bool? Status
        {
            get { return _status; }
            set
            {
                _status = value;
                this.DoNotify();
            }
        }
    }
}